﻿using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using LeanBoard.Models;

namespace LeanBoard
{
    public class InMemoryDataProvider : IDataProvider
    {
        private const string _path = @"C:\workspace\LeanBoard\_trunk\LeanBoard\LeanBoard\board.txt";

        public ItemsCollection GetItems(string team, string release)
        {
            BinaryFormatter bFormatter = new BinaryFormatter();
            Stream stream = File.Open(_path, FileMode.Open);
            ItemsCollection itemsCollection = bFormatter.Deserialize(stream) as ItemsCollection;
            stream.Close();
            return itemsCollection;
        }

        public DominoActionResult MoveItem(Item item)
        {
            return new DominoActionResult() { Status = "success", Message = "ok" };
        }

        public DominoActionResult Assign(string itemUnid, string name)
        {
            return new DominoActionResult() { Status = "success", Message = "ok" };
        }
    }
}